package db

import (
	"context"
	"database/sql"
	"fmt"
)

func TestDb() {
	db, err := sql.Open("postgres", "")
	if err != nil {
		panic(err)
	}

	defer db.Close()

	rows, err := db.QueryContext(context.Background(), "select id,name from user limit 100")
	if err != nil {
		panic(err)
	}

	defer rows.Close()

	var id, name string

	for rows.Next() {
		err = rows.Scan(&id, &name)
		if err != nil {
			panic(err)
		}

		fmt.Println("id: ", id, " name:", name)
	}

	err = rows.Err()
	if err != nil {
		panic(err)
	}
}
